/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package bpmn.impl;

import bpmn.BpmnPackage;
import bpmn.Expression;
import bpmn.MI_FlowConditionType;
import bpmn.MI_OrderingType;
import bpmn.MultiInstanceLoopActivity;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Multi Instance Loop Activity</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link bpmn.impl.MultiInstanceLoopActivityImpl#getMI_Condition <em>MI Condition</em>}</li>
 *   <li>{@link bpmn.impl.MultiInstanceLoopActivityImpl#getLoopCounter <em>Loop Counter</em>}</li>
 *   <li>{@link bpmn.impl.MultiInstanceLoopActivityImpl#getMI_Ordering <em>MI Ordering</em>}</li>
 *   <li>{@link bpmn.impl.MultiInstanceLoopActivityImpl#getMI_FlowCondition <em>MI Flow Condition</em>}</li>
 *   <li>{@link bpmn.impl.MultiInstanceLoopActivityImpl#getComplexMI_FlowCondition <em>Complex MI Flow Condition</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class MultiInstanceLoopActivityImpl extends ActivityImpl implements MultiInstanceLoopActivity {
	/**
	 * The cached value of the '{@link #getMI_Condition() <em>MI Condition</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMI_Condition()
	 * @generated
	 * @ordered
	 */
	protected Expression mI_Condition;

	/**
	 * The default value of the '{@link #getLoopCounter() <em>Loop Counter</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLoopCounter()
	 * @generated
	 * @ordered
	 */
	protected static final Integer LOOP_COUNTER_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getLoopCounter() <em>Loop Counter</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLoopCounter()
	 * @generated
	 * @ordered
	 */
	protected Integer loopCounter = LOOP_COUNTER_EDEFAULT;

	/**
	 * The default value of the '{@link #getMI_Ordering() <em>MI Ordering</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMI_Ordering()
	 * @generated
	 * @ordered
	 */
	protected static final MI_OrderingType MI_ORDERING_EDEFAULT = MI_OrderingType.SEQUENTIAL;

	/**
	 * The cached value of the '{@link #getMI_Ordering() <em>MI Ordering</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMI_Ordering()
	 * @generated
	 * @ordered
	 */
	protected MI_OrderingType mI_Ordering = MI_ORDERING_EDEFAULT;

	/**
	 * The default value of the '{@link #getMI_FlowCondition() <em>MI Flow Condition</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMI_FlowCondition()
	 * @generated
	 * @ordered
	 */
	protected static final MI_FlowConditionType MI_FLOW_CONDITION_EDEFAULT = MI_FlowConditionType.NONE;

	/**
	 * The cached value of the '{@link #getMI_FlowCondition() <em>MI Flow Condition</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMI_FlowCondition()
	 * @generated
	 * @ordered
	 */
	protected MI_FlowConditionType mI_FlowCondition = MI_FLOW_CONDITION_EDEFAULT;

	/**
	 * The cached value of the '{@link #getComplexMI_FlowCondition() <em>Complex MI Flow Condition</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getComplexMI_FlowCondition()
	 * @generated
	 * @ordered
	 */
	protected Expression complexMI_FlowCondition;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected MultiInstanceLoopActivityImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return BpmnPackage.Literals.MULTI_INSTANCE_LOOP_ACTIVITY;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Expression getMI_Condition() {
		if (mI_Condition != null && mI_Condition.eIsProxy()) {
			InternalEObject oldMI_Condition = (InternalEObject)mI_Condition;
			mI_Condition = (Expression)eResolveProxy(oldMI_Condition);
			if (mI_Condition != oldMI_Condition) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__MI_CONDITION, oldMI_Condition, mI_Condition));
			}
		}
		return mI_Condition;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Expression basicGetMI_Condition() {
		return mI_Condition;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMI_Condition(Expression newMI_Condition) {
		Expression oldMI_Condition = mI_Condition;
		mI_Condition = newMI_Condition;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__MI_CONDITION, oldMI_Condition, mI_Condition));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Integer getLoopCounter() {
		return loopCounter;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setLoopCounter(Integer newLoopCounter) {
		Integer oldLoopCounter = loopCounter;
		loopCounter = newLoopCounter;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__LOOP_COUNTER, oldLoopCounter, loopCounter));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MI_OrderingType getMI_Ordering() {
		return mI_Ordering;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMI_Ordering(MI_OrderingType newMI_Ordering) {
		MI_OrderingType oldMI_Ordering = mI_Ordering;
		mI_Ordering = newMI_Ordering == null ? MI_ORDERING_EDEFAULT : newMI_Ordering;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__MI_ORDERING, oldMI_Ordering, mI_Ordering));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MI_FlowConditionType getMI_FlowCondition() {
		return mI_FlowCondition;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMI_FlowCondition(MI_FlowConditionType newMI_FlowCondition) {
		MI_FlowConditionType oldMI_FlowCondition = mI_FlowCondition;
		mI_FlowCondition = newMI_FlowCondition == null ? MI_FLOW_CONDITION_EDEFAULT : newMI_FlowCondition;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__MI_FLOW_CONDITION, oldMI_FlowCondition, mI_FlowCondition));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Expression getComplexMI_FlowCondition() {
		if (complexMI_FlowCondition != null && complexMI_FlowCondition.eIsProxy()) {
			InternalEObject oldComplexMI_FlowCondition = (InternalEObject)complexMI_FlowCondition;
			complexMI_FlowCondition = (Expression)eResolveProxy(oldComplexMI_FlowCondition);
			if (complexMI_FlowCondition != oldComplexMI_FlowCondition) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__COMPLEX_MI_FLOW_CONDITION, oldComplexMI_FlowCondition, complexMI_FlowCondition));
			}
		}
		return complexMI_FlowCondition;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Expression basicGetComplexMI_FlowCondition() {
		return complexMI_FlowCondition;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setComplexMI_FlowCondition(Expression newComplexMI_FlowCondition) {
		Expression oldComplexMI_FlowCondition = complexMI_FlowCondition;
		complexMI_FlowCondition = newComplexMI_FlowCondition;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__COMPLEX_MI_FLOW_CONDITION, oldComplexMI_FlowCondition, complexMI_FlowCondition));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__MI_CONDITION:
				if (resolve) return getMI_Condition();
				return basicGetMI_Condition();
			case BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__LOOP_COUNTER:
				return getLoopCounter();
			case BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__MI_ORDERING:
				return getMI_Ordering();
			case BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__MI_FLOW_CONDITION:
				return getMI_FlowCondition();
			case BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__COMPLEX_MI_FLOW_CONDITION:
				if (resolve) return getComplexMI_FlowCondition();
				return basicGetComplexMI_FlowCondition();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__MI_CONDITION:
				setMI_Condition((Expression)newValue);
				return;
			case BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__LOOP_COUNTER:
				setLoopCounter((Integer)newValue);
				return;
			case BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__MI_ORDERING:
				setMI_Ordering((MI_OrderingType)newValue);
				return;
			case BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__MI_FLOW_CONDITION:
				setMI_FlowCondition((MI_FlowConditionType)newValue);
				return;
			case BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__COMPLEX_MI_FLOW_CONDITION:
				setComplexMI_FlowCondition((Expression)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__MI_CONDITION:
				setMI_Condition((Expression)null);
				return;
			case BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__LOOP_COUNTER:
				setLoopCounter(LOOP_COUNTER_EDEFAULT);
				return;
			case BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__MI_ORDERING:
				setMI_Ordering(MI_ORDERING_EDEFAULT);
				return;
			case BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__MI_FLOW_CONDITION:
				setMI_FlowCondition(MI_FLOW_CONDITION_EDEFAULT);
				return;
			case BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__COMPLEX_MI_FLOW_CONDITION:
				setComplexMI_FlowCondition((Expression)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__MI_CONDITION:
				return mI_Condition != null;
			case BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__LOOP_COUNTER:
				return LOOP_COUNTER_EDEFAULT == null ? loopCounter != null : !LOOP_COUNTER_EDEFAULT.equals(loopCounter);
			case BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__MI_ORDERING:
				return mI_Ordering != MI_ORDERING_EDEFAULT;
			case BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__MI_FLOW_CONDITION:
				return mI_FlowCondition != MI_FLOW_CONDITION_EDEFAULT;
			case BpmnPackage.MULTI_INSTANCE_LOOP_ACTIVITY__COMPLEX_MI_FLOW_CONDITION:
				return complexMI_FlowCondition != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (LoopCounter: ");
		result.append(loopCounter);
		result.append(", MI_Ordering: ");
		result.append(mI_Ordering);
		result.append(", MI_FlowCondition: ");
		result.append(mI_FlowCondition);
		result.append(')');
		return result.toString();
	}

} //MultiInstanceLoopActivityImpl
